/*******************************************************************************
 * Odbaul Mobile Client - PrefixMap.java 
 * Copyright (c) Vernalis Systems pvt ltd  2009 
 * This file is licensed from, and is a trade secret of:
 * 	Vernalis Systems pvt ltd
 * 	1,Shakthi Nagar
 * 	Mount Poonamallee road Porur
 * 	Chennai -116
 * TERMS OF USE: Refer your Software License Agreement
 *  Elton Kent - initial API and implementation
 ******************************************************************************/
package com.aphrodite.parser;

//import java.util.*;

/** Like Attribute, this class is immutable for similar reasons */

class PrefixMap {

	static final PrefixMap DEFAULT = new PrefixMap(null, "", "");

	private String namespace;
	private String prefix;
	private PrefixMap previous;

	PrefixMap(PrefixMap previous, String prefix, String namespace) {
		this.previous = previous;
		this.prefix = prefix;
		this.namespace = namespace;
	}

	/*
	 * String getNamespace () { return namespace; }
	 */

	/*
	 * String getPrefix () { return prefix; }
	 */

	/*
	 * PrefixMap getPrevious () { return previous; }
	 */

	/**
	 * returns the namespace associated with the given prefix, or null, if none
	 * is assigned
	 */

	String getNamespace(String prefix) {
		PrefixMap current = this;
		do {
			if (prefix.equals(current.prefix))
				return current.namespace;
			current = current.previous;
		} while (current != null);
		return null;
	}

	/*
	 * String getPrefix (String namespace) { PrefixMap current = this;
	 * 
	 * do { //System.err.println ("found: "+current.namespace +"/"+
	 * current.prefix + "/" +getNamespace (current.prefix)); if
	 * (namespace.equals (current.namespace) && namespace.equals (getNamespace
	 * (current.prefix))) return current.prefix;
	 * 
	 * current = current.previous; } while (current != null); return null; }
	 */
}
